package com.ludomancy.spaceopera;

import java.awt.Graphics;
import com.ludomancy.gamelib.ResourceManager;
import com.ludomancy.gamelib.WorldScreenProjection;
import com.ludomancy.gamelib.entity.World;
import com.ludomancy.spaceopera.entities.StationExit;

public class StationWorld extends World
{
	public StationWorld()
	{
		super(Game.WORLD_WIDTH, Game.WORLD_HEIGHT);
		
		// buttons
		StationButton[][] buttons = new StationButton[4][2];
		
		// fill them
		int ndx = 0;
		int paneX = 2000;
		int paneY = 500;
		int buttonGap = 200;
		int buttonWidth = new StationButton(null).getWidth();
		int buttonHeight = new StationButton(null).getHeight();
		for (int y = 0; y < buttons[0].length; y++)
		{
			for (int x = 0; x < buttons.length; x++)
			{
				if(Game.game.station.items[ndx] != null)
				{
					buttons[x][y] = new StationButton(Game.game.station.items[ndx]);
				}
				else
				{
					buttons[x][y] = new StationButton(null);
				}
				
				buttons[x][y].pos.x = paneX + x * (buttonWidth+buttonGap);
				buttons[x][y].pos.y = paneY + y * (buttonHeight+buttonGap);
				add(buttons[x][y]);
				ndx++;
			}
		}
		
		// exit
		add(new StationExit(Game.game.station.pos));
	}
	
	public void paint(Graphics g, WorldScreenProjection projector)
	{
		g.drawImage(ResourceManager.getImage("stationworld.png"), 0, 0, null);
		BasicEntity e = Game.game.player.interactableEntity;
		if(e instanceof StationButton)
		{
			StationButton button = (StationButton)e;
			GameTheme.theme.drawShadowText(g, button.getDescription(), 240, 290, 7);
		}
		super.paint(g, projector);
	}
	
	public void update()
	{
		super.update();
	}

}
